package cn.ltgodm.sandbox.service;

import cn.ltgodm.sandbox.service.impl.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

/**
 * @author ltgodm
 * @date 2024-03-10 19:13:23
 * 获取代码沙箱实现类的工厂
 */
@Configuration
public class CodeSandboxServiceFactory {
    @Autowired
    JavaCodeSandboxServiceImpl javaCodeSandboxService;
    @Autowired
    CPPShellSandboxServiceImpl cppShellSandboxService;
    @Autowired
    JavaShellSandboxServiceImpl javaShellSandboxService;
    @Autowired
    CShellSandboxServiceImpl cShellSandboxService;
    @Autowired
    PythonShellSandboxServiceImpl pythonShellSandboxService;
    @Autowired
    JSShellSandboxServiceImpl jsShellSandboxService;

    public CodeSandboxService getCodeSandboxByLanguage(String language) {
        switch (language) {
            case "java":
                return javaShellSandboxService;
            case "cpp":
                return cppShellSandboxService;
            case "c":
                return cShellSandboxService;
            case "python":
                return pythonShellSandboxService;
            case "javascript":
                return jsShellSandboxService;
            default:
                return javaCodeSandboxService;
        }
    }
}
